precision highp float; //指定浮点数精度为低精度
attribute vec3 inPosition;
//attribute vec4 inColor;
attribute vec2 inTexCoord0;
attribute vec2 inTexCoord1;
attribute vec3 inNormal;
//attribute vec4 inTangent;

varying vec3 outWorldPosition;
//varying vec4 outColor;
varying vec2 outTexCoord0;
varying vec2 outTexCoord1;
varying vec3 outWorldNormal;
//varying vec4 outTangent;

//varying mat3 outMatTtoW;

uniform mat4 matProj;
uniform mat4 matView;
uniform mat4 matModel;
uniform mat3 matNormal;



mat3 MatTtoW(vec3 normal, vec4 tangent) {
	//切线转世界矩阵
	vec3 N = normal;
	vec3 T = normalize(tangent.xyz - N * tangent.xyz * N);
	vec3 B = cross(N, T);
	mat3 matTtoW = mat3(T, B, N);
	return matTtoW;
}

void main(void) {
	gl_Position = (matProj * matView * matModel * vec4(inPosition, 1.0));
//	outColor = inColor;
	outTexCoord0 = inTexCoord0;
	outTexCoord1 = inTexCoord1;
	mat3 matNormal2 = mat3(matNormal[0],matNormal[1],matNormal[2]);
	outWorldNormal = normalize(matNormal2 * inNormal); //世界坐标法线
//	outWorldNormal = (matModel*vec4(inNormal,1.0)).rgb;
//	outWorldNormal = (matNormal*vec4(inNormal,1.0)).rgb;
//	outWorldPosition = matNormal * inPosition;
//	outTangent = inTangent;
	
//	outMatTtoW = MatTtoW(outWorldNormal,inTangent);
}
